package com.ch.d0415;

public class demo3 {
    public static void main(String[] args) {

        Thread t1 = new Thread( ()->{
           for(int i = 0;i < 20;i++) {
               System.out.println("扫地" + i);
               try {
                   Thread.sleep(80);
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }

           }
        });

        Thread t2 = new Thread( ()->{
            for(int i = 0;i < 20;i++) {
                System.out.println("擦窗" + i);

                try {
                    if (i==10) {
                        // 加入 t1 之后，在t1执行完之后，再执行
                        t1.join();
                    }
                    Thread.sleep(50);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

            }
        });

        t1.start();
        t2.start();


    }
}
